<?php

namespace app\common\model;

use think\Model;

class VideoChapter extends Model
{
    // 表名
    protected $name = 'video_chapter';


     /**
     * 视频课章节详情
     * user_id 用户id
     * video_id 视频id
     * video_status 视频状态 是否收费
     */
    public function getListVideoChapter($user_id,$video_id,$video_status){
        $list = $this->where(function ($query) use ($user_id,$video_id) {
            if ($video_id) {
                $query->where('video_id', $video_id);
            }
        })
        ->select();
        foreach ($list as &$v) {
            $v['duration'] = $v['duration'] > 0 ? round($v['duration'] / 60) : 0;
        }
        return $list;
    }

}